home *** CD-ROM | disk | FTP | other *** search
/ Gekkan Dennou Club 143 / Gekkan Dennou Club - 2000.4 Vol. 143 (Japan).7z / Gekkan Dennou Club - 2000.4 Vol. 143 (Japan).bin / ikap / grp1 / smp2 / spctest.c < prev    next >
C/C++ Source or Header  |  2000-03-06  |  4KB  |  233 lines

  1. /*
  2. */
  3. #include    <stdio.h>
  4. #include    <stdlib.h>
  5. #include    <iocslib.h>
  6.  
  7. #include    "structs.inc"
  8.  
  9.  
  10. extern int    HEY1[],YA00[];
  11.  
  12. TASK    ETask[MAX_ETASK];    /*クリック可能アイテム*/
  13.  
  14.  
  15.  
  16. #define        SetTask(tn,na,x,y,an)    \
  17.         t=&ETask[(tn)];    \
  18.         t->disp0_addr=(na);    \
  19.         t->disp0_x=(x)<<16;    \
  20.         t->disp0_y=(y)<<16;    \
  21.         t->disp0_anim=(an)
  22.  
  23. int    Init000()
  24. {
  25.     TASK    *t;
  26.  
  27.     CRTMOD(270);
  28.     HOME(0,0,0);
  29.     cls();
  30.     sp_init();
  31.     v_priority("TSG","0123");
  32.     sp_disp(1);
  33.     sp_on(0,127);
  34.     mouse(1);
  35.  
  36.     spfile_def("mue_m.SP",0x00);        /*スプライト読み込み*/
  37.     palfile_def("mue.PAL",0x01);
  38.  
  39. /*    t=&ETask[0]; t->disp0_addr=YOUW; t->disp0_x=128<<16; t->disp0_y=128<<16; t->disp0_anim=0;    */
  40.     SetTask(0,HEY1,228,180,0);
  41.     SetTask(1,YA00,228,180,0);
  42. }
  43.  
  44.  
  45.  
  46.  
  47. /*----------------------------------------------------------------------SyncMan()*/
  48.  
  49. #define        X6sp_set(pl,x,y,n,p)        \
  50.         X6sync_buf[(pl)*4+0]=(x);    \
  51.         X6sync_buf[(pl)*4+1]=(y);    \
  52.         X6sync_buf[(pl)*4+2]=(n);    \
  53.         X6sync_buf[(pl)*4+3]=(p)
  54.  
  55. short    X6sync_buf[128*4];
  56. int    SyncMan()
  57. {
  58.     int    ssp;
  59.     short    d,sppl;
  60.  
  61.     short    tn,sn,an,px,py,pat;
  62.     TASK    *t;            /*通常タスク*/
  63.  
  64.     SPINFO    *s;
  65.  
  66.     ssp=B_SUPER(0);
  67.  
  68.     sppl=0;
  69.     /*敵機
  70.     */
  71.     for( tn=0;tn<MAX_ETASK;tn++ ){
  72.         t=&ETask[tn];
  73. /*        if( t->func_addr==NULL ){    continue; }    */
  74.         if( t->disp0_addr==NULL ){    continue; }
  75.         s=t->disp0_addr;
  76.         if( s==NULL ){            continue; }
  77.         /*以下、表示
  78.         */
  79.         an=t->disp0_anim;
  80.         px=*(short *)&(t->disp0_x);
  81.         py=*(short *)&(t->disp0_y);
  82.         for( sn=0;sn<s->anim_info[t->disp0_anim]->chips;sn++ ){
  83.             px+=s->anim_info[t->disp0_anim]->splink[sn].ox;
  84.             py+=s->anim_info[t->disp0_anim]->splink[sn].oy;
  85.  
  86.             pat=s->anim_info[t->disp0_anim]->splink[sn].patnum;
  87.             if( t->disp0_palet!=0 ){
  88.                 pat&=0xf0ff;
  89.                 pat=pat|(t->disp0_palet<<8);
  90.             }
  91.  
  92.             X6sp_set(
  93.                 sppl,            /*実際に描画されるSPプレーン*/
  94.                 px,
  95.                 py,
  96.                 pat,
  97.                 3
  98.             );
  99.             sppl++;
  100.         }
  101.     }
  102.  
  103.  
  104.     /*スクロール
  105.     */
  106.     {
  107.         int    pn;
  108.         unsigned short    *spscr=0xEB0000,
  109.                 *sync=X6sync_buf;
  110.         for( pn=0;pn<min(sppl,128);pn++ ){
  111.             *spscr++=(*sync+16);sync++;
  112.             *spscr++=(*sync+16);sync++;
  113.             *spscr++=*sync++;
  114.             *spscr++=*sync++;
  115.         }
  116.         sp_off(sppl,127);
  117.     }
  118.  
  119.     {
  120.         unsigned short    *vctrl_r2=0xE82600;
  121.         *vctrl_r2|=0x0040;
  122.     }
  123.  
  124.     B_SUPER(ssp);
  125. }
  126.  
  127.  
  128.  
  129.  
  130. int    voffwait(times)
  131. int    times;
  132. {
  133.     volatile unsigned char    *gpip=0xe88001;
  134.     int    t,ssp;
  135.  
  136.     ssp=B_SUPER(0);
  137.     for( t=0;t<times;t++ ){
  138.         while((*gpip&0x10));
  139.         while(!(*gpip&0x10));
  140.     }
  141.     B_SUPER(ssp);
  142.  
  143. }
  144.  
  145.  
  146.  
  147. void    Idle()
  148. {
  149.     static    int    local_counter;
  150.     short    *anum;
  151.     int    *dx,*dy,*vx,*vy;
  152.     int    mx,my;
  153.     
  154.     
  155.     
  156.     mspos(&mx,&my);
  157.     
  158.     
  159.     /*弓引き兵隊
  160.     */
  161.     anum=&(ETask[0].disp0_anim);
  162.     switch( local_counter%60 ){
  163.         case 0:    *anum=0;    break;
  164.         case 3:    *anum=1;    break;
  165.         case 6:    *anum=2;    break;
  166.         case 9:    *anum=3;    break;
  167.     }
  168.     
  169.     
  170.     /*矢
  171.     */
  172.     anum=&(ETask[1].disp0_anim);
  173.     vx=(int *)&(ETask[1].work[0]);
  174.     vy=(int *)&(ETask[1].work[2]);
  175.     dx=(int *)&(ETask[1].work[4]);
  176.     dy=(int *)&(ETask[1].work[6]);
  177.     switch( local_counter%60 ){
  178.         case 0:
  179.             *anum=0;
  180.             *vx=0;
  181.             *vy=0;
  182.             *dx=0;
  183.             *dy=0;
  184.             
  185.             ETask[1].disp0_x=ETask[0].disp0_x;
  186.             ETask[1].disp0_y=ETask[0].disp0_y;
  187.         break;
  188.         case 9:
  189.             *anum=1;
  190. /*
  191.             *vx=-0x100000;
  192.             *vy=-0x10000;
  193. */
  194.             *vx=-(rand()%32+32)<<12;
  195.             *vy=-(rand()%32+16)<<12;
  196.             *dx=0;
  197.             *dy=-(*vy/12);
  198.         break;
  199.     }
  200.     if( (local_counter%60)>9 ){
  201.         *vx+=*dx;    //加速
  202.         *vy+=*dy;
  203.     }
  204.     ETask[1].disp0_x+=*vx;
  205.     ETask[1].disp0_y+=*vy;
  206.  
  207.  
  208.     local_counter++;
  209. }
  210.  
  211.  
  212.  
  213. main(argc,argv)
  214. int    argc;
  215. char    *argv[];
  216. {
  217.     int    mn;
  218.     Init000();
  219.     mn=(ETask[0].disp0_addr)->max_anim;
  220.     while( BITSNS(0)!=0x02 ){
  221.         SyncMan();
  222.         Idle();
  223.         voffwait(1);
  224.     }
  225.     while( BITSNS(0)==0x02 );
  226.     KFLUSHIO(0xff);
  227. }
  228.  
  229.  
  230.  
  231. /* [ EOF ] */
  232.  
  233.